package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CancelRequest;
import com.pgybook.db.entity.domain.CancelRequestEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CancelRequestMapper {
    int countByExample(CancelRequestEx example);

    int deleteByExample(CancelRequestEx example);

    @Delete({
            "delete from cancelrequest",
            "where CANCELREQID = #{cancelreqid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer cancelreqid);

    @Insert({
            "insert into cancelrequest (CUSTID, PHONE, ",
            "CONTACT, BANK, BANKACCOUNT, ",
            "ACCOUNTNAME, AMOUNT, ",
            "STATUS, REQTYPE, ",
            "REQREASON, STAFFID, ",
            "STAFFREMARK, REQUESTTIME, ",
            "HANDLETIME)",
            "values (#{custid,jdbcType=BIGINT}, #{phone,jdbcType=VARCHAR}, ",
            "#{contact,jdbcType=VARCHAR}, #{bank,jdbcType=VARCHAR}, #{bankaccount,jdbcType=VARCHAR}, ",
            "#{accountname,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL}, ",
            "#{status,jdbcType=INTEGER}, #{reqtype,jdbcType=INTEGER}, ",
            "#{reqreason,jdbcType=VARCHAR}, #{staffid,jdbcType=INTEGER}, ",
            "#{staffremark,jdbcType=VARCHAR}, #{requesttime,jdbcType=TIMESTAMP}, ",
            "#{handletime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "cancelreqid", before = false, resultType = Integer.class)
    int insert(CancelRequest record);

    int insertSelective(CancelRequest record);

    List<CancelRequest> selectByExample(CancelRequestEx example);

    @Select({
            "select",
            "CANCELREQID, CUSTID, PHONE, CONTACT, BANK, BANKACCOUNT, ACCOUNTNAME, AMOUNT, ",
            "STATUS, REQTYPE, REQREASON, STAFFID, STAFFREMARK, REQUESTTIME, HANDLETIME",
            "from cancelrequest",
            "where CANCELREQID = #{cancelreqid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CancelRequest selectByPrimaryKey(Integer cancelreqid);

    int updateByExampleSelective(@Param("record") CancelRequest record, @Param("example") CancelRequestEx example);

    int updateByExample(@Param("record") CancelRequest record, @Param("example") CancelRequestEx example);

    int updateByPrimaryKeySelective(CancelRequest record);

    @Update({
            "update cancelrequest",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "PHONE = #{phone,jdbcType=VARCHAR},",
            "CONTACT = #{contact,jdbcType=VARCHAR},",
            "BANK = #{bank,jdbcType=VARCHAR},",
            "BANKACCOUNT = #{bankaccount,jdbcType=VARCHAR},",
            "ACCOUNTNAME = #{accountname,jdbcType=VARCHAR},",
            "AMOUNT = #{amount,jdbcType=DECIMAL},",
            "STATUS = #{status,jdbcType=INTEGER},",
            "REQTYPE = #{reqtype,jdbcType=INTEGER},",
            "REQREASON = #{reqreason,jdbcType=VARCHAR},",
            "STAFFID = #{staffid,jdbcType=INTEGER},",
            "STAFFREMARK = #{staffremark,jdbcType=VARCHAR},",
            "REQUESTTIME = #{requesttime,jdbcType=TIMESTAMP},",
            "HANDLETIME = #{handletime,jdbcType=TIMESTAMP}",
            "where CANCELREQID = #{cancelreqid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CancelRequest record);
}
